


use health/test_daily_panel, clear

egen week = cut(date), at(`=mdy(3,13,2020)'(7)`=mdy(12,22,2020)')			
collapse (max) positive tested, by(week sid)	
collapse (sum) tested positive, by(week)
tempfile pop_rates
save `pop_rates', replace 


use health/inp_clean if ~no_dx, clear
gen test_non = test_tight if any_icli==0
gen test_icli = test_tight if any_icli == 1

	egen week = cut(admit_date), at(`=mdy(3,13,2020)'(7)`=mdy(12,22,2020)')		
collapse (sum) test_icli test_non ,	by(week)

merge m:1 week using `pop_rates'

gen share_both = (test_icli + test_non)/tested
gen share_icli = (test_icli )/tested
gen share_non = ( test_non)/tested

sum share_both share_icli share_non if week>=mdy(3,1,2020)

gen c0 = "var &" in 1
gen c1 = "share \\" in 1

local row = 1
foreach t in both icli non {
	local ++row
	sum share_`t'  if week>=mdy(3,1,2020)
	replace c0 ="`t' &" in `row'
	replace c1 = string(r(mean),"%4.3f") + "\\" in `row'
}

list c0 c1 in 1/4, noobs clean
outsheet c0 c1 using tables/hospital_test_share.tex, replace noquote ///	
	nonames delimit(" ")
